package org.sauceggplant.item.man.ui.panel;

import org.sauceggplant.item.man.ui.constant.Constants;
import org.sauceggplant.item.man.ui.frame.MainFrame;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.swing.*;
import java.awt.*;

public class MainPanel extends JPanel {

    private static final Logger logger = LoggerFactory.getLogger(MainPanel.class);

    private MainFrame frame;

    private ItemPanel itemPanel;

    private TypePanel typePanel;

    public MainPanel(MainFrame frame) {
        this.frame = frame;
        init();
    }

    private void init() {
        initComponent();
    }

    private void initComponent() {
        this.setLayout(new BorderLayout());
        JTabbedPane tabbedPane = new JTabbedPane();
        logger.info("物品界面加载中...");
        itemPanel = new ItemPanel(frame);
        String itemTitle = MainFrame.PROPERTIES.getProperty(Constants.ITEM_TITLE);
        tabbedPane.add(itemTitle, itemPanel);
        logger.info("物品界面加载完成.");
        logger.info("类别加载中...");
        typePanel = new TypePanel(itemPanel, frame);
        String typeTitle = MainFrame.PROPERTIES.getProperty(Constants.TYPE_TITLE);
        tabbedPane.add(typeTitle, typePanel);
        logger.info("类别界面加载完成.");
        this.add(tabbedPane, BorderLayout.CENTER);
    }
}
